package com.ido.news.splashlibrary.bean;

import com.google.gson.Gson;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;

public class BeanResponse implements Serializable {

    /**
     * data : [{"adExtendData":"{\"mtPackageName\":\"com.dotools.weather\",\"mtVersionCode\":\"200\",\"mtType\":\"DOWNLOAD\",\"mtUrl\":\"http://balance2.chinacloudapp.cn/com.dotools.weather_gjx.apk\",\"mtImage\":\"http://oss.tv163.com/toolbox/d74e8e64-8afa-4e65-8f3d-b7898d1959e3.png\"}","adIsOpen":true,"adSupportType":"FIRST_GDT","adType":"LAUNCH_AD"}]
     * statusCode : 200
     * timeStamp : 1533883413
     */
    private int statusCode;
    private int timeStamp;
    private String errorMsg;
    private List<DataBean> data;

    public int getStatusCode() {
        return statusCode;
    }

    public void setStatusCode(int statusCode) {
        this.statusCode = statusCode;
    }

    public int getTimeStamp() {
        return timeStamp;
    }

    public void setTimeStamp(int timeStamp) {
        this.timeStamp = timeStamp;
    }

    public List<DataBean> getData() {
        return data;
    }

    public void setData(List<DataBean> data) {
        this.data = data;
    }

    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    public static class DataBean {
        /**
         "adType":"LAUNCH_AD",
         "adCustomData":"",
         "adIsOpen":true,
         "adVid":"37ff21e0b1ae11e98fc77cd30abeb94e",
         "adSupportType":"THREE_PARTY_SEQUENCE",
         "adExtendData":"{\"sequence\":[\"TOUTIAO\",\"GDT\"],\"self\":{\"mtPackageName\":null,\"mtVersionCode\":100,\"mtType\":\"OPEN\",\"mtUrl\":\"https://oss.idourl.com/upload/20210120/cc1b77b48b144657be3d8d4b3e8e9d59.apk\",\"mtImage\":\"https://oss.idourl.com/upload/20210120/3e27fb3b97f447d688f7ad546060648f.jpg\"}}"
         */

        private String adExtendData;
        private String adCustomData;
        private boolean adIsOpen;
        private String adSupportType;
        private String adType;
        private String adVid;

        public String getAdVid() {
            return adVid;
        }

        public void setAdVid(String adVid) {
            this.adVid = adVid;
        }


        public HashMap<String, Object> getExtendDataMap() {
            try {
                Gson gson = new Gson();
                HashMap<String, Object> sequenceDataMap = gson.fromJson(this.adExtendData, HashMap.class);
                return sequenceDataMap;
            } catch (Exception e) {
                e.printStackTrace();
                return null;
            }
        }

        /**
         * 获取旧版自营数据转map使用
         */
        public HashMap<String, String> getOldSelfDataMap() {
            try {
                Gson gson = new Gson();
                HashMap<String, String> selfDataMap = gson.fromJson(this.adExtendData, HashMap.class);
                return selfDataMap;
            } catch (Exception e) {
                e.printStackTrace();
                return null;
            }
        }


        public boolean isAdIsOpen() {
            return adIsOpen;
        }


        public String getAdSupportType() {
            return adSupportType;
        }

        public String getAdExtendData() {
            return adExtendData;
        }

        public HashMap<String, Object> getCustomDataMap() {
            try {
                Gson gson = new Gson();
                HashMap<String, Object> customDataMap = gson.fromJson(this.adCustomData, HashMap.class);
                return customDataMap;
            } catch (Exception e) {
                e.printStackTrace();
                return null;
            }
        }

        public String getAdCustomData() {
            return adCustomData;
        }


        public String getAdType() {
            return adType;
        }

        public void setAdType(String adType) {
            this.adType = adType;
        }

    }

    @Override
    public String toString() {
        return "BeanResponse{" +
                "statusCode=" + statusCode +
                ", timeStamp=" + timeStamp +
                ", errorMsg='" + errorMsg + '\'' +
                ", data=" + data +
                '}';
    }
}
